package com.twu.biblioteca;

import java.util.ArrayList;
import java.util.List;

public class UserService {
    List<String> accountMenu =new ArrayList<String>();
    public UserService() {
        accountMenu.add("Login");
        accountMenu.add("UserInformation");
        accountMenu.add("BackMainmenu");
        accountMenu.add("Quit");
    }
    public boolean userLogin(String userId, String password) {
        boolean result=false;
        Account account=getAccountById(userId);
        if(account!=null&&account.getPassword().equals(password)){
            result=true;
        }
        return result;
    }

    public Account getAccountById(String userId) {
        for(Account account :Library.accountList){
            if(account.getAccountId().equals(userId)){
                return account;
            }
        }
        return null;
    }
    public void accountMenu(){
        System.out.print("UserMenu:*");
        for(String s: accountMenu) {
            System.out.print("   "+s+"   *");
        }
        System.out.println();
        System.out.println("*******************************************************************************");

    }

    public void printAccountInformation(Account account){
        System.out.println("*******************************************************************************");
        System.out.println("                              User  Information                     ");
        System.out.println("accountId" + "   " + "name" + "         " + "email" + "                 " + "phoneNumber");
        System.out.println(account.toString());
    }
}
